/* GUI CONVERTED from utindel.p (converter v1.75) Tue Aug 29 11:11:54 2000 */
/* utindel.p - DELETE UNREFERENCED IN_MSTR RECORDS                            */
/* Copyright 1986-2000 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.8.1.5 $                                                          */
/*F0PN*/ /*V8:ConvertMode=Report                                              */
/* REVISION: 7.3   LAST MODIFIED: 04/16/93   BY: pma *G961*                   */
/* Oracle changes (share-locks)   09/13/94   BY: rwl *FR32*                   */
/* REVISION: 8.5   LAST MODIFIED: 08/01/96   BY: *J13J* Markus Barone         */
/* REVISION: 8.5   LAST MODIFIED: 01/13/98   BY: *J28L* Manmohan Pardesi      */
/* REVISION: 8.6E  LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane             */
/* REVISION: 8.6E  LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan            */
/* REVISION: 8.6E  LAST MODIFIED: 09/15/98   BY: *J2YY* Mugdha Tambe          */
/* REVISION: 9.0   LAST MODIFIED: 02/24/99   BY: *M089* Jean Miller           */
/* REVISION: 9.0   LAST MODIFIED: 03/13/99   BY: *M0BD* Alfred Tan            */
/* REVISION: 9.0   Last Modified: 06/01/99   By: *M0CV* Jean Miller           */
/* REVISION: 9.1   LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane      */
/* REVISION: 9.1   LAST MODIFIED: 08/24/00   BY: *N0KB* Jean Miller           */

/*J13J*/ {mfdtitle.i "b+ "}

/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

/* ********** Begin Translatable Strings Definitions ********* */

/*N0KB* &SCOPED-DEFINE utindel_p_1 "Deleted" */
/* MaxLen: Comment: */

/* ********** End Translatable Strings Definitions ********* */

         define variable part  like in_part no-undo.
         define variable part1 like in_part no-undo.
         define variable site  like in_site no-undo.
         define variable site1  like in_site no-undo.
         
         define new shared variable showdetail like mfc_logical no-undo.

         define variable prog_name like mnd_exec no-undo.
         define variable i    as integer no-undo.
/*J28L*  define variable msg  as character format "x(78)" extent 10. */
/*J28L*/ define variable msg  as character format "x(78)" extent 14 no-undo.
/*J28L*  define variable msg1 as character format "x(65)" extent 10. */
/*J28L*/ define variable msg1 as character format "x(65)" extent 8 no-undo.
/*J28L*/ define variable filename like _file-name no-undo.
/*J28L*/ define variable table_list as character no-undo.
         define variable f_part like _field-name no-undo.
         define variable f_site like _field-name no-undo.
         define new shared variable inrecno as recid.
/*J28L*  define new shared variable filename like _file-name. */
         define new shared variable yn like mfc_logical.
/*N0KB*/ define variable del-text as character format "x(12)" no-undo.

/*J28L*  define new shared frame b. */
/*J28L*/ define new shared frame indel.
         define new shared stream prt.

/*N0KB*/ del-text = getTermLabel("DELETED",12).

         /* Get Informational Text */
/*N0KB*/ {gpcdget.i "UT"}

/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
            
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
part      colon 20
            part1     colon 49 label {t001.i} skip
            site      colon 20 
    site1     colon 49 label {t001.i} skip 
    showdetail colon 20 skip(1)
         with frame a side-labels width 80 attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:HIDDEN in frame a = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5.  /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME

         /* SET EXTERNAL LABELS */
         setFrameLabels(frame a:handle).

         view frame a.

         repeat:

            if part1 = hi_char then part1 = "".
            if site1 = hi_char then site1 = "".

            update
               part
               part1
               site
               site1
               showdetail
            with frame a.

            bcdparm = "".

            {mfquoter.i part   }
            {mfquoter.i part1  }
            {mfquoter.i site   }
            {mfquoter.i site1   }
            {mfquoter.i showdetail   }

            if part1 = "" then part1 = hi_char.
            if site1 = "" then site1 = hi_char.


            /* SELECT PRINTER */
            {mfselbpr.i "printer" 80 " " "stream prt"}
/*GUI*/ RECT-FRAME:HEIGHT-PIXELS in frame a = FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.

            {mfphead2.i "stream prt" "(prt)"}

            /****************************************************************/
            /* THE FOLLOWING CODE IS INSERTED HERE FOR THE DEVELOPER ONLY.  */
            /* IT CREATES THE PROGRAM UTINDELA.P WHICH IS SPECIFIC TO EACH  */
            /* DATABASE RELEASE.  THE GENERATED PROGRAM SHOULD ONLY BE USED */
            /* TO COMPARE AGAINST THE EXISTING UTINDELA.P CODE TO ADD NEW   */
            /* SCHEMA OR DELETE OLD SCHEMA.                                 */
            /****************************************************************/

            loopb:
            for each in_mstr where (in_part >= part and in_part <= part1)
/*J28L*/    and in_site >= site and in_site <= site1 exclusive-lock with frame indel:

               {utindel.i}  /*frame indel*/

               inrecno = recid(in_mstr).
               display stream prt in_part in_site WITH STREAM-IO /*GUI*/ .
               
               yn = yes.
               find first ld_det where ld_part = in_part
                   and ld_site = in_site
                   and ld_qty_oh <> 0
               no-lock no-error.
               if available ld_det then yn = no.
               if (showdetail or yn = no) then do:
                   display stream prt "ld_det" @ filename yn WITH STREAM-IO /*GUI*/ .
                   down stream prt 1.
               end.
               if not yn then next loopb.

               yn = yes.
               find first lad_det where lad_part = in_part
                    and lad_site = in_site
                    and lad_qty_all <> 0
                    and lad_qty_chg <> 0
                    and lad_qty_pick <> 0
               no-lock no-error.
               if available ld_det then yn = no.
               if (showdetail or yn = no) then do:
                   display stream prt "lad_det" @ filename yn WITH STREAM-IO /*GUI*/ .
                   down stream prt 1.
               end.
               if not yn then next loopb.

/*J2YY*/       /* BEGIN ADD SECTION */

               for each iro_det exclusive-lock
                  where iro_part = in_part
                    and iro_site = in_site:

                  if iro_cost_set begins "cumorder" then do:

                     if can-find( first wo_mstr where wo_type = "C"
                                                  and wo_nbr  = " "
                                                  and wo_lot  =  iro_routing )
                     then  next .
                     else delete iro_det .

                  end. /* IF IRO_COST_SET = "CUMORDER" THEN */
                  else delete iro_det .

               end. /* FOR EACH IRO_DET */

/*J2YY*/       /* END ADD SECTION   */

/*J28L*  ADDED 4 PARAMETERS TO THE CALL TO utindela.p */
               {gprun.i ""utindela.p""
                "(input inrecno,
                  input 'FRM',
                  input table_list,
                  output filename,
                  output yn")}
                  
               if not yn then next loopb.

/*FR32*/       for each sct_det exclusive-lock
               where sct_site = in_site and sct_part = in_part:
/*FR32*/          for each spt_det exclusive-lock where spt_sim = sct_sim
                  and spt_part = sct_part and spt_site = sct_site:
                     delete spt_det.
                  end.
                  delete sct_det.
               end.
/*N0KB*        display stream prt "spt_det" @ filename {&utindel_p_1} @ yn. */
/*N0KB*/       display stream prt "spt_det" @ filename del-text @ l-text WITH STREAM-IO /*GUI*/ .
               down stream prt 1.
/*N0KB*        display stream prt "sct_det" @ filename {&utindel_p_1} @ yn. */
/*N0KB*/       display stream prt "sct_det" @ filename del-text @ l-text WITH STREAM-IO /*GUI*/ .
               down stream prt 1.

/*FR32*/       for each ld_det exclusive-lock
               where ld_part = in_part and ld_site = in_site:
/*FR32*/          for each lad_det exclusive-lock where lad_site = ld_site
                  and lad_loc = ld_loc and lad_part = ld_part
                  and lad_lot = ld_lot and lad_ref = ld_ref:
                     delete lad_det.
                  end.
                  delete ld_det.
               end.
/*N0KB*        display stream prt "ld_det" @ filename {&utindel_p_1} @ yn. */
/*N0KB*/       display stream prt "ld_det" @ filename del-text @ l-text WITH STREAM-IO /*GUI*/ .
               down stream prt 1.
/*N0KB*        display stream prt "lad_det" @ filename {&utindel_p_1} @ yn. */
/*N0KB*/       display stream prt "lad_det" @ filename del-text @ l-text WITH STREAM-IO /*GUI*/ .
               down stream prt 1.

               display stream prt in_part in_site WITH STREAM-IO /*GUI*/ .
               delete in_mstr.
/*N0KB*        display stream prt "in_mstr" @ filename {&utindel_p_1} @ yn. */
/*N0KB*/       display stream prt "in_mstr" @ filename del-text @ l-text WITH STREAM-IO /*GUI*/ .
               down stream prt 2.
            end.

            {mftrl080.i "stream prt"}

         end.
